<template>
    <div class="layerRtb layerRtb-threecolumn">
        <three-title :title="{name:'积分'}"></three-title>
         <div class="layerRtb-scroll thinScroll" v-scrollHeight="437">
                <div class="analyItem" @click="clickFourShow(0)">
                    <p class="analyItemTit tx-center">历史</p>
                    <div class="analyItemCon">
                        <p class="col-md-3">
                            <span>{{(integral?(integral.aggregateIntegral-(complaints?complaints.haPenalty:0)-(JcountIntegral?(JcountIntegral.deductFraction/JcountIntegral.deductNum):0)-(TcountIntegral?(TcountIntegral.deductFraction/TcountIntegral.deductNum):0)):0)}}分</span>
                        </p>
                         <p class="col-md-3">
                            <span>当前{{integral.userLevel}} 级</span>
                        </p>
                         <p class="col-md-3">
                            <span>-60分</span>
                        </p>
                         <p class="col-md-3">
                            <span>下级别{{integral.nextLevel}} 级</span>
                        </p>
                    </div>
                </div>
                <div class="analyItem">
                    <p class="analyItemTit tx-center">结余</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                            <span>结余{{integral.surplusIntegra}}分</span>
                        </p>
                    </div>
                </div>
                <div class="analyItem">
                    <p class="analyItemTit tx-center">投诉</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                           <span>当前积分-</span>
                            <span>{{tIntegral}}分</span>
                        </p>
                    </div>
                </div>
                <div class="analyItem">
                    <p class="analyItemTit tx-center">拒单</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                            <span>当前积分-</span>
                            <span>{{JcountIntegral?(Number(JcountIntegral.deductFraction)/Number(JcountIntegral.deductNum)):0}}分</span>
                        </p>
                    </div>
                </div>
                 <div class="analyItem">
                    <p class="analyItemTit tx-center">退单</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                            <span>当前积分-</span>
                            <span>{{TcountIntegral?(Number(TcountIntegral.deductFraction)/Number(TcountIntegral.deductNum)):0}}分</span>
                        </p>
                    </div>
                </div>
                 <div class="analyItem">
                    <p class="analyItemTit tx-center">管理</p>
                    <div class="analyItemCon">
                        <p class="col-md-12">
                           <span>当前积分-</span>
                            <span>{{McountIntegral?McountIntegral.integtral:0}}分 </span>
                        </p>
                    </div>
                </div>
        </div>
        <div class="layerRtb-footer">
            <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                    <div class="analyItemCon">
                        <p class="col-md-4">
                            <span>{{integral.aggregateIntegral-tIntegral-(JcountIntegral?JcountIntegral.deductFraction/JcountIntegral.deductNum:0)-(TcountIntegral?TcountIntegral.deductFraction/TcountIntegral.deductNum:0)}}分</span>
                        </p>
                         <p class="col-md-4">
                            <span>{{integral.userLevel}}级降{{integral.nextLevel}} 级</span>
                        </p>
                         <p class="col-md-4">
                            <span>距离降{{integral.nextLevel}} 级需扣{{60+Number(integral.aggregateIntegral)}}分</span>
                        </p>
                    </div>
            </div>
        </div>
    <transition-group class="animated faster" enter-active-class="animated faster slideInRight" leave-active-class="animated faster slideOutRight">
        <!-- 问题 threeresultDetail -->
        <rx-history v-if="fourIndex === 0" :key="0" :basic="basic"></rx-history>
    </transition-group>
    </div>
</template>
<script>
import { mapGetters } from 'vuex'
import { getDepositDetail, getIntegralStatus, countcomplaintsIntegral, PersonHandlerIntegralNum, getProblemIntegral } from '../../Resources/Api/index'
import rxHistory from './IntegralHistory/history'
export default {
    components: {
        rxHistory
    },
    data () {
        return {
            Complaint: [],
            fourIndex: undefined,
            integral: {},
            JcountIntegral: {},
            TcountIntegral: {},
            McountIntegral: {},
            CcountIntegral: {},
            tIntegral: 0,
            tIntegralObject: {}
        }
    },
    created () {
        this.integral = this.$route.query.integral
        this.GetJCountIntegral()
        this.GetTCountIntegral()
        this.GetMCountIntegral()
        this.GetCCountIntegral()
        this.ProblemIntegral()
    },
    methods: {
        GetDeposit () {
            let _this = this
            getDepositDetail({
                uId: _this.leftInfo.uid,
                flag: 1
            })
        },
        clickFourShow (index) {
            this.fourIndex = index
        },
        ProblemIntegral () {
            let _this = this
            getProblemIntegral({
                pmId: this.leftInfo.uid
            }).then(result => {
                _this.tIntegralObject = result.data.Body.problemIntegralList
                _this.tIntegral = result.data.Body.problemIntegralList.map(list => list.integral).reduce((acc, cur) => (parseFloat(cur) + acc), 0)
            }).catch(err => {
                console.log(err)
            })
        },
        /*  GetIntegral () {
            let _this = this
            _this.integral = {}
            getIntegralMsg({
                uid: this.leftInfo.uid
            }).then(results => {
                this.integral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        }, */
        GetJCountIntegral () {
            let _this = this
            _this.JcountIntegral = {}
            getIntegralStatus({
                uid: this.leftInfo.uid,
                dataSource: 13,
                integralType: 2
            }).then(results => {
                this.JcountIntegral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },

        GetTCountIntegral () {
            let _this = this
            _this.TcountIntegral = {}
            getIntegralStatus({
                uid: this.leftInfo.uid,
                dataSource: 14,
                integralType: 1
            }).then(results => {
                this.TcountIntegral = results.data.Body
            }).catch(error => {
                console.log(error)
            })
        },
        GetMCountIntegral () {
            let _this = this
            _this.McountIntegral = {}
            PersonHandlerIntegralNum({
                userCard: this.leftInfo.app_cardNo
            }).then(result => {
                this.McountIntegral = result.data.Body
            })
        },
        GetCCountIntegral () {
            let _this = this
            _this.CcountIntegral = {}
            countcomplaintsIntegral({
                uid: this.leftInfo.uid
            }).then(result => {
                this.CcountIntegral = result.data.Body
            })
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    watch: {
        leftInfo () {
            this.GetProjectManagerResult()
            this.GetJCountIntegral()
            this.GetTCountIntegral()
            this.GetMCountIntegral()
            this.GetCCountIntegral()
        }
    }
}

</script>
